package ian.android.lovewords.settings;

import ian.android.lovewords.R;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore.Audio;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

/**
 * Display the alarm information 
 */
public class MyAlarm extends Activity {

    /**
     * An identifier for this notification unique within your application
     */
    public static final int NOTIFICATION_ID=1; 
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.my_alarm);
         stopService(new Intent(this, MyService.class));
       
        // create the instance of NotificationManager
        final NotificationManager nm=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
        // create the instance of Notification
        //int icon = R.drawable.ic_launcher;
        //Notification n=new Notification(icon,"Finished",System.currentTimeMillis());
        /* set the sound of the alarm. There are two way of setting the sound */
          // n.sound=Uri.parse("file:///sdcard/alarm.mp3");
        //n.sound=Uri.withAppendedPath(Audio.Media.INTERNAL_CONTENT_URI, "20");
        
        /*Context context = getApplicationContext();
        CharSequence contentTitle = "My notification";
        CharSequence contentText = "Hello World!";
        Intent notificationIntent = new Intent(this, NotifiyActivity.class);
        PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
        n.setLatestEventInfo(context, contentTitle, contentText, contentIntent);*/
        // Post a notification to be shown in the status bar
        //nm.notify(NOTIFICATION_ID, n);
        
        /* display some information */
        TextView tv=(TextView)findViewById(R.id.tvNotification);
        tv.setText("Hello, it's time to bla bla...");
        
        /* the button by which you can cancel the alarm */
        Button btnCancel=(Button)findViewById(R.id.btnCancel);
        btnCancel.setOnClickListener(new View.OnClickListener() {
            
            @Override
            public void onClick(View arg0) {
                nm.cancel(NOTIFICATION_ID);
                finish();
            }
        });
    }
    
}
